#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
LL dp[21][11][11][5][2];//0-inc 1-des
int main(){
	int n,t;
	while(cin>>n>>t){
		memset(dp,0,sizeof(dp));
		for(int j=1;j<=4;j++)for(int k=1;k<=4;k++)if(j!=k)dp[2][0][0][j][k>j]++;
		
		for(int i=3;i<=n;i++){
			for(int x=0;x<=t;x++){//convex
				for(int y=0;y<=t-1;y++){//concave
					for(int j=1;j<=4;j++){
						for(int k=1;k<=4;k++)if(j!=k){
							for(int p=0;p<=1;p++){
								if(!dp[i-1][x][y][k][p])continue;
								int xx=x+(k>j&&p==0&&i>2),yy=y+(k<j&&p==1&&i>2),pp=(k>j);
								if(xx<=t&&yy<=t-1)dp[i][xx][yy][j][pp]+=dp[i-1][x][y][k][p];
								}
							}
						}
					}
				}
			}
		LL ans=0;
		for(int j=1;j<=4;j++)ans+=(dp[n][t][t-1][j][0]+dp[n][t][t-1][j][1]);
		cout<<ans<<endl;
		}
    return 0;
    }
